package com.woniuxy.controller;

import com.woniuxy.entity.Address;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/addressController")
public class AddressController {
    @Autowired
    private AddressService addressService;

    //查询所有
    @GetMapping("/address")
    public ResponseEntity findAll(){
        return addressService.findAll();
    }

    //查询一个
    @GetMapping("/address/{id}")
    public ResponseEntity findOne(@PathVariable int id){
        return addressService.findOne(id);
    }

    //增加一个
    @PostMapping("/address")
    public ResponseEntity addOne(@RequestBody Address address){
        return addressService.addOne(address);
    }

    //删除一个
    @DeleteMapping("/address/{id}")
    public ResponseEntity delete(@PathVariable int id){
        return addressService.delete(id);
    }

    //修改一个
    @PutMapping("/address")
    public ResponseEntity update(@RequestBody Address address){
        return addressService.update(address);
    }
}
